﻿using FastReport;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Drawing;
using System.Drawing.Printing;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinFormsApp1.Common;

namespace WinFormsApp1.SuYi.Week3WinForm
{
    public partial class CheckDeailShow : Form
    {
        public CheckDeailShow()
        {
            InitializeComponent();
            SupplierShow();
            SettlementTypeShow();
            Show();
        }

        /// <summary>
        /// 供应商下拉框绑定
        /// </summary>
        public async void SupplierShow()
        {
            var items = await HttpClientHelper.RequestUrl<object, ApiResult<List<Suppliers>>>(URLCommon.Url2, "/CheckIn/SupplierShow", HttpClientHelper.MethodType.POST, null);
            uiComboBox2.DataSource = items.Data;
            uiComboBox2.DisplayMember = "SupplierName";
            uiComboBox2.ValueMember = "SupplierId";

            this.Controls.Add(uiComboBox2);
        }
        /// <summary>
        /// 供应商
        /// </summary>
        public class Suppliers
        {
            public int SupplierId { get; set; }
            public string SupplierName { get; set; }
        }
        /// <summary>
        /// 进场类型下拉框绑定
        /// </summary>
        public async void SettlementTypeShow()
        {
            var items = await HttpClientHelper.RequestUrl<object, ApiResult<List<SettlementType>>>(URLCommon.Url2, "/CheckIn/SettlementTypeShow", HttpClientHelper.MethodType.POST, null);
            uiComboBox1.DataSource = items.Data;
            uiComboBox1.DisplayMember = "SettlementTypeName";
            uiComboBox1.ValueMember = "SettlementTypeId";

            this.Controls.Add(uiComboBox1);
        }

        /// <summary>
        /// 进场类型
        /// </summary>
        public class SettlementType
        {
            public int SettlementTypeId { get; set; }
            public string SettlementTypeName { get; set; }
        }

        private async void Show()
        {
            //var data = new CheckInDeailDto
            //{
            //    PageIndex = PageIndex,
            //    PageSize = PageSize,
            //    CheckInNo = CheckInNo,
            //    QuarantineNo = QuarantineNo,
            //    EnterTime = EnterTime,
            //    SupplierId = SupplierId,
            //    SettlementTypeId = SettlementTypeId,
            //    OriginAddr = OriginAddr,
            //};
            //var items = await HttpClientHelper.RequestUrl<object, ApiResultFY1<List<CheckInDeailDto>>>("http://localhost:5106/api/Reports/", "QueryCheckDetail", HttpClientHelper.MethodType.POST, data);

        }

        public int PageIndex = 1;
        public int PageSize = 100;
        public string CheckInNo = "";
        public string QuarantineNo = "";
        public DateTime? EnterTime = null;
        public int SupplierId = 0;
        public int SettlementTypeId = 0;
        public string OriginAddr = "";

        private void uiButton1_Click(object sender, EventArgs e)
        {
            if (uiDatePicker1.Text != " ")
            {
                EnterTime = Convert.ToDateTime(uiDatePicker1.Text);
            }
            if (uiComboBox1.Text != null)
            {
                SupplierId = Convert.ToInt32(uiComboBox1.SelectedValue);
            }
            if (uiComboBox2.Text != null)
            {
                SettlementTypeId = Convert.ToInt32(uiComboBox2.SelectedValue);
            }
            CheckInNo = uiTextBox1.Text;
            QuarantineNo = uiTextBox2.Text;
            OriginAddr = uiTextBox3.Text;
            CheckDeail checkDeail = new CheckDeail();
            checkDeail.ShowDialog();

        }

    }
}
